<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'newCarSaleInfoPh.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">

	<link rel="stylesheet" type="text/css" href="mok/newcar/css/newCarSale.css">

	<script type="text/javascript" src="js/common.js"></script>
	
	<script type="text/javascript" src="dwr/engine.js"></script>
	<script type="text/javascript" src="dwr/util.js"></script>
	<script type="text/javascript" src="dwr/interface/basicCarService.js"></script>
	
	<script type="text/javascript">
			function brandChange(value){
				var brand = document.getElementById('brand'); 
				var department = document.getElementById('department');
				var carType = document.getElementById('carType');
				dwr.engine.setAsync(false);
				basicCarService.getDepartmentListByBrand(value, 
					function (data){
						department.options.length = 1;
						for(var i = 0; i < data.length; i++){
							department.options.add(new Option(data[i]));
						}
					}
				);
				dwr.engine.setAsync(true);
				carType.selectedIndex = 0;
			}
			function departmentChange(value){
				var carType = document.getElementById('carType');
				
				dwr.engine.setAsync(false);
				basicCarService.getCarTypeListByDepartment(value, 
					function (data){
						carType.options.length = 1;
						for(var i = 0; i < data.length; i++){
							carType.options.add(new Option(data[i]));
						}
					}
				);
				dwr.engine.setAsync(true);
			}
			
			function init(){
				var brands = document.getElementById('brand'); 
				var departments = document.getElementById('department');
				var carTypes = document.getElementById('carType');
				var brand = "${request.brand}";
				var department = "${request.department}";
				var carType = "${request.carType}";
				alert(brand);
				alert(department);
				alert(carType);
				if(brand != ""){
					for(var i=0; i<brands.length; i++){
						if(brands[i].value == brand){
							document.getElementById('brand').options[i].selected=true;
							break;
						}
					}
				}
				if(department != ""){
					for(var i=0; i<departments.length; i++){
						if(departments[i].value == department){
							document.getElementById('department').options[i].selected=true;
							break;
						}
					}
				}
				if(carType != ""){
					for(var i=0; i<carTypes.length; i++){
						if(carTypes[i].value == carType){
							document.getElementById('carType').options[i].selected=true;
							break;
						}
					}
				}
			}
		</script>
	
	
  </head>
  
  <body>
    
    <div id="main">
    	<div class="basic_parameters_tit" style="height: 80">
    	<form action="newcar/newCarAction_CarTypeQuery" method="post">
    		<table>
    		<tr style="height: 40">
			<td>起始时间：</td><td><input id="startTime" name="startTime" type="text" size="15" readonly="readonly" value="${request.startTime}">
 		<a href="javascript:void(0)" onclick="gfPop.fPopCalendar(document.getElementById('startTime'));return false;">
    	<img name="popcal" align="absmiddle" src="images/selectDate.gif" width="15" height="12" border="0" alt=""></a>
			<td>结束时间：</td><td><input id="endTime" name="endTime" type="text" size="15" readonly="readonly" value="${request.endTime}">
 		<a href="javascript:void(0)" onclick="gfPop.fPopCalendar(document.getElementById('endTime'));return false;">
    	<img name="popcal" align="absmiddle" src="images/selectDate.gif" width="15" height="12" border="0" alt=""></a></td></tr> 
    	<tr style="height: 40"><td>品&nbsp;&nbsp;&nbsp;&nbsp;牌：<td><select style="font-size: 14px; text-align: center;width:120;height:20" id="brand" name="brand"
									onchange="brandChange(this.options[this.options.selectedIndex].value);">
									<option value="0">
										请选择
									</option>
									<s:iterator var='brand' value="#request.brands">
										<option>
											<s:property value="#brand" />
										</option>
									</s:iterator>
								</select></td>
		<td>车&nbsp;&nbsp;&nbsp;&nbsp;系：</td><td><select id="department" name="department" onchange="departmentChange(this.options[this.options.selectedIndex].value);" style="font-size: 14px; text-align: center;width:120;height:20">
				<option value="0">请选择</option></select></td>
		<td>车&nbsp;&nbsp;&nbsp;&nbsp;型：</td><td><select id="carType" name="carType" style="font-size: 14px; text-align: center;width:120;height:20">
				<option value="0">请选择</option></select></td>
		<td style="width: 100;text-align: center;"><input type="submit" value="查询"></td>
    	</tr>
    	</table></form>
		</div>
			<table class="basic_parameters_content">
				<tr>
					<td>排名</td><td>车型</td><td>销售总量</td><td>百分比</td><tr>
				<tr>
				<s:iterator value="#request.sList" var="bean">
					<td><s:property value="#bean.id"/></td>
					<td><s:property value="#bean.name"/></td>
					<td><s:property value="#bean.num"/></td>
					<td>${fn:substring(bean.scale,0,5)}%</td><tr>
				<tr>
				</s:iterator>
			</table>
	
    </div>
    <div style="height: 50"></div>
   <iframe width=174 height=189 name="gToday:normal:agenda.js" id="gToday:normal:agenda.js" src="common/calendar/ipopeng.htm" scrolling="no" frameborder="0" style="visibility:visible; z-index:999; position:absolute; left:-500px; top:0px;"></iframe>
  </body>
</html>
